package cn.tannn.cat.file.server.controller.manage.dto;

import cn.tannn.cat.file.server.enums.DictStatus;
import cn.tannn.cat.file.server.enums.DictType;
import cn.tannn.jdevelops.annotations.jpa.JpaSelectIgnoreField;
import cn.tannn.jdevelops.annotations.jpa.JpaSelectOperator;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLConnect;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLOperatorWrapper;
import cn.tannn.jdevelops.jpa.request.PagingSorteds;
import cn.tannn.jdevelops.result.bean.SerializableBean;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 分页查询字典
 *
 * @author <a href="https://tannn.cn/">tan</a>
 * @date 2024/3/8 10:12
 */
@Schema(description = "分页查询字典")
@ToString
@Getter
@Setter
@Valid
public class DictPage  extends SerializableBean<DictPage> {

    /**
     * 字典标签
     */
    @Schema(description = "字典标签")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.LIKE, connect = SQLConnect.AND)
    private String label;

    /**
     * 字典键值
     */
    @Schema(description = "字典键值")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.EQ, connect = SQLConnect.AND)
    private String value;

    /**
     * 字典类型
     * @see DictType
     */
    @Schema(description = "字典类型")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.EQ, connect = SQLConnect.AND)
    private DictType dictType;

    /**
     * 状态
     * @see DictStatus
     */
    @Schema(description = "字典状态")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.EQ, connect = SQLConnect.AND)
    private DictStatus status;

    /**
     * 分页排序
     */
    @Schema(description = "分页排序")
    @JpaSelectIgnoreField
    @Valid
    private PagingSorteds page;



    public PagingSorteds getPage() {
        if(page == null){
            return new PagingSorteds().fixSort(0,"sort");
        }else {
            return page.append(0,"sort");
        }
    }

}
